﻿@model EM.OA.Portal.Models.RemindModels
@{
    Layout = "~/Views/Shared/_LayoutContent.cshtml";
}
@*<script type="text/javascript" src="~/Scripts/page/Remind.js"></script>*@
<script>
    var objectID;
    $(function () {
        //根据提醒类型显示内容
        $("#remindType input:radio").click(function () {
            var divID = "div" + $(this).attr("id");
            $("div[id^='div']").css("display", "none");
            if ($(this).attr("checked"))
                $("#" + divID).css("display", "block");
            $("#divInstant").css("display", "block");
            //设置单选按钮的状态
            var radioID = $(this).attr("id");
            $("#remindType input:radio").each(function () {
                if ($(this).attr("id") == radioID)
                    $(this).attr("checked", "checked");
                else
                    $(this).removeAttr("checked");
            });
        });

        //增加日下拉选择框
        var obj = document.getElementById('month');
        for (var i = 1; i <= 31; i++) {
            obj.options.add(new Option(i, i));
        }
        //设置当前天
        var today = new Date();
        obj.options[today.getDate() - 1].selected = true;
        //当前月－日
        var currMonth = today.getMonth() + 1;
        $("#monthDay").html(currMonth + "-" + today.getDate());

        //根据重复类型显示内容
        $("#repeatType").change(function () {
            var divID = "div" + $(this).attr("value");
            $("div[id='divMulti'] > div[id]").css("display", "none");
            $("#" + divID).css("display", "block");
        });
    });
    //删除
    function del() {
        var objectID = $("#objectID").val();
        $.post('/Remind/Delete', { id: objectID },
            function (result) {
                if (result == 'OK') {
                    $(window.frames["frmRemind"].document).find("#del").click();//调用提醒功能保存提醒模块
                    $("#list").datagrid('clearSelections');
                    $('#list').datagrid('reload');    // reload the user data  
                } else {
                    $.messager.show({   // show error message  
                        title: 'Error',
                        msg: result
                    });
                }
            });
    }

</script>
<div>
    <form id="fmRemind" method="post" style="font-size: 12px">
        @Html.Hidden("objectID", @ViewData["RemindObjectID"].ToString())
        <input type="submit" id="create" name="create" value="Submit" style="display: none" />
        <input type="submit" id="edit" name="edit" value="edit" style="display: none" />
        <div id="remindType">
            <input type="radio" name="Instant" id="Instant" checked="checked" /><label for="Instant">即时提醒</label>
            <input type="radio" name="Single" id="Single" /><label for="Single">单次提醒</label>
            <input type="radio" name="Multi" id="Multi" /><label for="Multi">重复提醒</label>
        </div>
        <div id="divSingle" style="display: none;">
            提醒时间：<input name="singleRemindTime" class="easyui-datetimebox" data-options="required:true,showSeconds:false" />
        </div>
        <div id="divMulti" style="display: none;">
            <div>
                重复频率:
            <select id="repeatType" name="repeatType">
                <option value="3">每天</option>
                <option value="4">每周</option>
                <option value="5">每月</option>
                <option value="6">每年</option>
            </select>
            </div>
            <div id="div4" style="display: none">
                重复日期：<input type="checkbox" id="1" name="week1" /><label for="1">周一</label>
                <input type="checkbox" id="2" name="week2" /><label for="2">周二</label>
                <input type="checkbox" id="3" name="week3" /><label for="3">周三</label>
                <input type="checkbox" id="4" name="week4" /><label for="4">周四</label>
                <input type="checkbox" id="5" name="week5" /><label for="5">周五</label>
                <input type="checkbox" id="6" name="week6" /><label for="6">周六</label>
                <input type="checkbox" id="7" name="week7" /><label for="7">周日</label>
            </div>
            <div id="div5" style="display: none">
                提醒日期：
                <select id="month" name="month">
                </select>日
            </div>
            <div id="div6" style="display: none">
                提醒日期：<input name="monthDay" id="monthDay" class="easyui-datebox" data-options="required:true" />
                <script>
                    $('#monthDay').datebox({
                        required: true,
                        formatter: function (date) {
                            var m = date.getMonth() + 1;
                            var d = date.getDate();
                            return date.pattern("MM-dd");
                        }
                    });
                </script>

            </div>
            提醒时间：<input name="multiRemindTime" class="easyui-timespinner" data-options="required:true" />
            <br />
            开始日期：<input name="startDate" class="easyui-datebox" />
            <br />
            结束日期：<input name="endDate" class="easyui-datebox" />
        </div>
        <div id="divInstant">
            <input type="checkbox" id="Mail" name="Mail" /><label for="Mail">邮件提醒</label>&nbsp;
            <input type="checkbox" id="SMS" name="SMS" /><label for="SMS">短信提醒</label>&nbsp;
            <input type="checkbox" id="WebMessage" name="WebMessage" /><label for="WebMessage">短消息提醒</label>
        </div>
    </form>
</div>
